package org.itworks.biodev.gui.panels;

import java.awt.event.ActionEvent;
import java.util.Arrays;
import javax.swing.JOptionPane;
import org.itworks.helpers.mvc.*;

public class ParametersPanelControler extends AbstractControler {
	private ParametersPanelModel model;
	private String password = "toto";
	public ParametersPanelControler(ParametersPanelModel model) {
		this.model = model;
	}
	char[] charsPassword = password.toCharArray();

	public void validationButtonActionPerformed(ActionEvent actionEvent, char[] oldPasswordField, char[] newPasswordField, char[] confirmNewPasswordField) {
		// TODO Auto-generated method stub
		try {
			if(Arrays.equals(charsPassword,oldPasswordField)) {
				if(Arrays.equals(newPasswordField,confirmNewPasswordField)) {
					charsPassword = newPasswordField;
					JOptionPane.showMessageDialog(null, "Mot de passe changé avec succes", "Succes", JOptionPane.INFORMATION_MESSAGE);
					}
				else {
					JOptionPane.showMessageDialog(null, "Nouveau mot de passe incorrect", "Erreur", JOptionPane.ERROR_MESSAGE);
				}
			}
			else {
				JOptionPane.showMessageDialog(null, "Ancien mot de passe incorrect", "Erreur", JOptionPane.ERROR_MESSAGE);
			}
		}
		
		catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public void viewLoaded() {
		// TODO Auto-generated method stub
		
	}
}
